package r25.room;

import java.util.List;

import r25.character.ICharacter;
import r25.character.IInRoomObject;
import r25.engine.Event;
import r25.engine.IEvent.EVENT;
import r25.engine.IGameInstance;
import r25.engine.IGameInstance.CHARACTER_ACTION;

/**
 * As soon as two characters are in this room, the one who entered earlier is
 * eliminated by the arrival of the second one
 * 
 * @author u211354
 * 
 */
public class AcidBath extends AbstractRoom {
	@Override
	public CHARACTER_ACTION onEnter(IGameInstance gi, ICharacter character)
			throws Exception {
		CHARACTER_ACTION rc = super.onEnter(gi, character);

		List<IInRoomObject> chs = gi.getInRoomObjects(this, false);
		for (IInRoomObject iro : chs) {
			ICharacter ch = (ICharacter) iro;
			// kill anyone else character
			if (!ch.equals(character)) {
				ch.setAlive(false);
				gi.pushEvent(new Event(EVENT.DEATH, this, ch));
			}
		}
		return rc;
	}

}
